package com.xyhy.core.base.lookup;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import com.xyhy.core.base.entity.NamedObject;

public class LookupType extends LookupKeyVal<String> {

  public LookupType() {
  }

  public LookupType(String id, String name) {
    super(id, name);
  }

  public LookupType(NamedObject<String> namedObject) {
    super(namedObject.getId(), namedObject.getName());
  }

  public static <T extends NamedObject<String>> List<LookupType> values(List<T> datas) {
    return datas.stream().map(x -> new LookupType(x.getId(), x.getName())).collect(Collectors.toList());
  }

  @Override
  public String getId() {
    return id;
  }

  @Override
  public int hashCode() {
    return Objects.hashCode(id);
  }

}
